//================================================
//
//  Slavon.net menu v0,7b "over" lib
//
//================================================


if(typeof HTMLElement!="undefined"){
if(!HTMLElement.prototype.insertAdjacentElement){
	HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode)
	{
		switch (where){
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling)             
				this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}


	HTMLElement.prototype.insertAdjacentText = function(where,txtStr)
	{
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}
if (!HTMLElement.prototype.innerHTML){
	HTMLElement.prototype.innerHTML = function (str) {
	   var r = this.ownerDocument.createRange();
	   r.selectNodeContents(this);
	   r.deleteContents();
	   var df = r.createContextualFragment(str);
	   this.appendChild(df);
	   return str;
	}
	
	HTMLElement.prototype.outerHTML = function (str) {
	   var r = this.ownerDocument.createRange();
	   r.setStartBefore(this);
	   var df = r.createContextualFragment(str);
	   this.parentNode.replaceChild(df, this);
	   return str;
	}
}
}

var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

var tttt = "";

function getRef(id) {
    if (isDOM) return document.getElementById(id);
    if (isIE4) return document.all[id];
    if (isNS4) return document.layers[id];
}

function getSty(id) {
    return (isNS4 ? getRef(id) : getRef(id).style);
} 

var menu_show = new Array();
var menu_gen = new Array();
var menu_id = "";
var menu_x = 0;
var menu_y = 0;
var popTimer = 0;
// var menu = new Array();

function Item(pid, text, url, img, img_over, type, ori, div_style, table_style, td_style //, temp1, temp2, ..., tempN
		){
	this.pid = pid;
	this.text = text;
	this.url = url;
	this.img = (img?img:false);
	this.img_over = (img_over?img_over:false);
	this.ori = ori;
	this.type = type;
	this.div_style = (div_style?div_style:false);
	this.table_style = (table_style?table_style:false);
	this.td_style = (td_style?td_style:false);
	this.x = 0;
	this.y = 0;
	this.h = 0;
	this.w = 0;

// !!! Uncoment for arguments !!!
/*	if(Item.arguments.length>10){
		var a = Item.arguments; 
		for(i=1; (i+9)<a.length; i++)
			eval("this.temp" + i + "= a[i+9]");
	}
-*/
}

function check_sys(){
	if (!isDOM) return true;
	var temp = new Array();
	var i = "";
	var hide;

	temp[temp.length] = menu_status;
	if (menu_status != 0)
		if(menu[menu_status].pid !=0)
//		alert(!(menu[menu_status].table_style == 1));
//		if(!(menu[menu_status].table_style == 1))
		{
			i=menu[menu_status].pid;
			temp[temp.length] = i;
			while (menu[i].pid != 0){
//			while (!(menu[i].table_style == 1 || menu[i].table_style == 2)){
				i=menu[i].pid;
				temp[temp.length] = i;
			}
		}


	for(i=0; i<menu_show.length; i++){
	hide = true;
		for(j=0; j<temp.length; j++){
			if(menu_show[i] == temp[j]){
				hide = false;
				break;
			}
		}
		if(hide == true){
			if(getRef("a" + menu_show[i]))
				getSty("a" + menu_show[i]).visibility = "hidden";
		}


	}
// ADDED
//`	alert(tttt);
//
//	if(tttt){
//	if (getRef("a" + tttt)){
//		if (getSty("a" + tttt).visibility == "hidden"){
//			getRef("td_x_" + tttt).style.background = "#0A5F09";
//			if (menu[tttt].img && !menu[tttt].div_style)
//				getRef("td_y_" + tttt).src = menu[tttt].img;
//			tttt = '';
//		}
//	}else{
//		if(popTimer){
///			getRef("td_x_" + tttt).style.background = "#0A5F09";
//			if (menu[tttt].img && !menu[tttt].div_style)
//				getRef("td_y_" + tttt).src = menu[tttt].img;
//			tttt = '';
//		}
//	}
//	}
// \ADDED
}

function td_menu_over(id){
	if (!isDOM) return true;
	clearTimeout(popTimer);
	write_menu_custom(id);
	menu_status = id;
	check_sys();
	popTimer = 0;
// ADDED
//	if (menu[id].pid == 0 && getRef("a" + id)){
//		getRef("td_x_" + id).style.background = "#007500";
//		tttt = id;
//	}
//	if (menu[id].pid == 0){
//		getRef("td_x_" + id).style.background = "#007500";
//			if (menu[id].img_over && !menu[id].div_style)
//			getRef("td_y_" + id).src = menu[id].img_over;
//		tttt = id;
//	}

// \ADDED
	if (getRef("a" + id) && id != ''){
		getSty("a" + id).visibility = "visible";
		var add = true;
		for(i=0; i<menu_show.length; i++)
			if(menu_show[i] == id)
				add = false;
		if (add == true)
			menu_show[menu_show.length] = id;
	}
	check_sys();
}

function td_menu_out(){
	menu_status = 0;
	clearTimeout(popTimer);
	popTimer = setTimeout('check_sys()', 600);
}